#ifndef X_A_H
#define X_A_H

#include "common.h"

// DRC, not fully decoded
template <AllegroVersion version>
struct x0A
{
    uint16_t t;
    uint8_t subtype;
    uint8_t layer;
    uint32_t k;
    uint32_t next;
    uint32_t un1; // Always null?
    int32_t coords[4];
    uint32_t un4[4];
    uint32_t un5[5];
    
    uint32_t TAIL;
    operator x0A<A_174>() const;
    static constexpr AllegroVersion versions[2] = {A_172, A_174};
};

#if __cplusplus >= 202002L
template <AllegroVersion version> requires(version >= A_172)
struct x0A<version>
{
    uint16_t t;
    uint8_t subtype;
    uint8_t layer;
    uint32_t k;
    uint32_t next;
    uint32_t un1; // Always null?
    uint32_t un2;
    int32_t coords[4];
    uint32_t un4[4];
    uint32_t un5[5];
    COND_FIELD(version >= A_174, uint32_t, un3);

    uint32_t TAIL;
    operator x0A<A_174>() const;
    static constexpr AllegroVersion versions[2] = {A_172, A_174};
};
#else
template <> struct x0A<A_172>
{
    uint16_t t;
    uint8_t subtype;
    uint8_t layer;
    uint32_t k;
    uint32_t next;
    uint32_t un1; // Always null?
    uint32_t un2;
    int32_t coords[4];
    uint32_t un4[4];
    uint32_t un5[5];

    uint32_t TAIL;
    operator x0A<A_174>() const;
    static constexpr AllegroVersion versions[2] = {A_172, A_174};
};

template <> struct x0A<A_174>
{
    uint16_t t;
    uint8_t subtype;
    uint8_t layer;
    uint32_t k;
    uint32_t next;
    uint32_t un1; // Always null?
    uint32_t un2;
    int32_t coords[4];
    uint32_t un4[4];
    uint32_t un5[5];
    uint32_t un3;

    uint32_t TAIL;
    operator x0A<A_174>() const;
    static constexpr AllegroVersion versions[2] = {A_172, A_174};
};
#endif

#endif // X_A_H
